#include "stdafx.h"
#include "BaseComClass.h"

static XLLRTGlobalAPI  luaBaseComClassMemberFuns[]=
{
	{"AttachEventListener",CBaseComClass::AttachEventListener},
	{"__gc",CBaseComClass::DeleteSelf},
	{NULL,NULL}
};

int CBaseComClass::RegisterClass(XL_LRT_ENV_HANDLE hEnv)
{
	if(hEnv==NULL)
		return 0;
	return XLLRT_RegisterClass(hEnv,BASECOMCLASS_CLASS,luaBaseComClassMemberFuns,NULL,0);
}

int CBaseComClass::AttachEventListener(lua_State* luaState)
{
	return 1;
}

int CBaseComClass::DeleteSelf(lua_State* luaState)
{
	return 1;
}

int CBaseComClass::ListenerCallBack(DWORD dwParam1,DWORD dwParam2,int nIndex)
{
	return 1;
}



//--------------------------//
CBaseComClassFactory::m_pObj=NULL;

static XLLRTGlobalAPI  luaBaseComClassFactoryMemberFuns[]=
{
	{"CreateInstance",CBaseComClassFactory::CreateInstance},
	{NULL,NULL}
};

CBaseComClassFactory* CBaseComClassFactory::Instance()
{
	if(m_pObj==NULL)
		m_pObj=new CBaseComClassFactory();
	return m_pObj;
}

int CBaseComClassFactory::CreateInstance(lua_State* luaState)
{
	CBaseComClass* pBaseComClass=new CBaseComClass();
	XLLRT_PushXLObject(luaState,BASECOMCLASS_CLASS,pBaseComClass);
}

void CBaseComClassFactory::RegisterObj(XL_LRT_ENV_HANDLE hEnv)
{
	if(hEnv==NULL)
		return;
	XLLRTObject lrtObj;
	lrtObj.ClassName=BASECOMCLASS_FACTORY_CLASS;
	lrtObj.MemberFunctions=luaBaseComClassFactoryMemberFuns;
	lrtObj.ObjName=BASECOMCLASS_FACTORY_OBJ;
	lrtObj.userData=NULL;
	lrtObj.pfnGetObject=(fnGetObject)CBaseComClassFactory::Instance;

	XLLRT_RegisterGlobalObj(hEnv,lrtObj);
}